﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Business.Handlers.ProjectNamesHandler;
using ETL.Business.Handlers.ProjectTaskHandler;
using ETL.Business.Handlers.ProjectTimeHandler;
using ETL.Business.Handlers.SessionHandler;
using ETL.Common;
using ETL.Common.Logging;

namespace ETL.Business.Helpers
{
    /// <summary>
    /// as Page_Load or Form_Load
    /// </summary>
    public class ProgramInitialize
    {
        public ProgramInitialize()
        {
            
        }
        public virtual void Execute(string userId, string userName)
        {
            try
            {
                // set loading progress
                (new SetSessionData()).Execute(Constants.SessionVars.Loading, "True");

                // set session data of current logged on user
                (new SetSessionData()).Execute(Constants.SessionVars.UserId, userId);
                (new SetSessionData()).Execute(Constants.SessionVars.UserName, userName);

                // check network status 

                // startup routines
                //RA (new StartUp()).Execute(userId);

                // setup the listview
                // ------ Set up columns, size, etc.. ----------

                // Get selected project
                var selectedProject = (new GetSelectedProject()).Execute(userId);
                if (selectedProject.HasValue)
                {
                    (new SetSessionData()).Execute(Constants.SessionVars.SelectedProject, selectedProject.Value.ToString());
                }

                // calculate time spent on projects
                //RA(new Calc()).Execute(userId, userName);

                // unset loading progress
                (new SetSessionData()).Execute(Constants.SessionVars.Loading, "False");
            }
            catch (Exception ex)
            {
                LogService.Service.Error(ex);
                throw;
            }
        }
    }
}
